home *** CD-ROM | disk | FTP | other *** search
/ Internet 53 / INTERNET53.iso / pc / software / windows / building / coldfusion studio evaluation / data1.cab / CFS_Wizards / CFML / TreeControl_TreeControl.wml < prev    next >
Encoding:
Text File  |  1998-10-08  |  4.0 KB  |  151 lines

  1. <WIZIF ItemIcons NEQ 2>
  2.     <WIZSET IconImage1 = "Folder">
  3. <WIZELSE>
  4.     <WIZSET IconImage1 = "Document">
  5. </WIZIF>
  6.  
  7. <WIZIF ItemIcons EQ 0>
  8.     <WIZSET IconImage2 = "Folder">
  9. <WIZELSE>
  10.     <WIZSET IconImage2 = "Document">
  11. </WIZIF>
  12.  
  13.  
  14. <HTML><HEAD>
  15.     <TITLE>$${ApplicationName} - $${RootItem}</TITLE>
  16. </HEAD><BODY bgcolor="ffffff">
  17.  
  18.  
  19. <FONT size="+1">$$ApplicationName</FONT> <BR>
  20. <FONT size="+2"><B>$${RootItem}</B></FONT>
  21.  
  22. <P>
  23.  
  24.  
  25. <!---- group fields are the source for the tree? ---->
  26. <WIZIF TreeSourceType EQ '1'>
  27.  
  28.  
  29. <WIZSET QueryFieldList = ''>
  30. <WIZSET QueryOrderByList = ''>
  31. <WIZSET FieldCount = '0'>
  32. <WIZLOOP index="CurrentField" list="$${GroupFields}">
  33.     <WIZSET FieldCount = FieldCount + 1>
  34.     <!---- field is in format 'sTable.sField=sType;nSize;bRequired' ---->
  35.     <WIZSET SeparatorPos = Find( CurrentField, '=' )>
  36.     <WIZSET TableFieldName = Left( CurrentField, SeparatorPos - 1 )>
  37.     <WIZSET QueryFieldList = QueryFieldList & TableFieldName & ' AS GroupField' & FieldCount & ', '>
  38.     <WIZSET QueryOrderByList = QueryOrderByList & TableFieldName & ', '>
  39. </WIZLOOP>
  40. <WIZSET QueryFieldList = Left( QueryFieldList, Len(QueryFieldList) - 2 )>
  41. <WIZSET QueryOrderByList = Left( QueryOrderByList, Len(QueryOrderByList) - 2 )>
  42.  
  43. <WIZSET QueryTableList = ''>
  44. <WIZLOOP index="i" list="$${Tables}">
  45.   <WIZSET QueryTableList = QueryTableList & i & ', '>
  46. </WIZLOOP>
  47. <WIZSET QueryTableList = Left( QueryTableList, Len(QueryTableList) - 2 )>
  48.  
  49. <WIZSET QueryJoinList = ''>
  50. <WIZLOOP index="i" list="$${Joins}">
  51.   <WIZSET QueryJoinList = QueryJoinList & i & ' AND '>
  52. </WIZLOOP>
  53. <WIZIF QueryJoinList EQ ''>
  54.   <WIZSET WhereClause = ''>
  55. <WIZELSE>
  56.   <WIZSET WhereClause = 'WHERE ' & Left( QueryJoinList, Len(QueryJoinList) - 5 )>
  57. </WIZIF>
  58.  
  59. <CFQUERY name="GetTreeData" dataSource="$${DataSource}">
  60.     SELECT DISTINCT $${QueryFieldList}
  61.     FROM $${QueryTableList}
  62.     $${WhereClause}
  63. </CFQUERY>
  64.  
  65.  
  66. <CFFORM action="$${ActionURL}">
  67.  
  68. <CFTREE name = "Tree"
  69.     height = "600"
  70.     width = "300"
  71.     highlightRef = "no"
  72.     >
  73.     
  74.     <CFSET GroupField0 = 0>
  75.     <CFTREEITEM value="#GroupField0#" display="$${RootItem}" expand="yes">
  76.     
  77.     <CFSET CurGroup1 = "">
  78.     <CFLOOP query="GetTreeData">
  79.  
  80. <WIZLOOP index="i" from="1" to="$${FieldCount - 1}">
  81.         <CFIF CurGroup$${i} is not GroupField$${i}>
  82.             <CFTREEITEM value="#GroupField$${i}#" parent="#GroupField$${ i - 1 }#" display="#GroupField$${i}#" img="$${IconImage1}" expand="no">
  83.             <CFSET CurGroup$${i} = GroupField$${i}>
  84.             <CFSET CurGroup$${i+1} = ''>
  85.         </CFIF>
  86. </WIZLOOP>
  87.  
  88.  
  89.         <CFTREEITEM value="#GroupField$${FieldCount}#" parent="#GroupField$${ FieldCount - 1 }#" display="#GroupField$${FieldCount}#" img="$${IconImage2}" expand="no">
  90.  
  91.     </CFLOOP>
  92.  
  93. </CFTREE>
  94.     
  95. <P>
  96.  
  97. <INPUT type="Submit" value="Open" name="btnOpen">
  98.  
  99. </CFFORM>
  100.  
  101.  
  102.  
  103. <!---- ...else ID and parentID fields are the source for the tree? ---->
  104. <WIZELSE>
  105.  
  106. <WIZSET SeparatorPos = Find( IDField, '=' )>
  107. <WIZSET ItemID = Left( IDField, SeparatorPos - 1 )>
  108.  
  109. <WIZSET SeparatorPos = Find( ParentIDField, '=' )>
  110. <WIZSET ParentItemID = Left( ParentIDField, SeparatorPos - 1 )>
  111.  
  112. <CFQUERY name="GetTreeData" dataSource="$${DataSource}">
  113.     SELECT $${ItemID} AS ItemID, $${ParentItemID} AS ParentItemID
  114.     FROM $${Tables}
  115. </CFQUERY>
  116.  
  117. <!--- If the CFX_MAKE_TREE tag extension is not installed on your server,
  118.     you have to install it. The extension is available for download from 
  119.     CF_TagGallery at www.allaire.com --->
  120. <CFX_MAKE_TREE query="GetTreeData">
  121.  
  122. <CFFORM action="$${ActionURL}">
  123.  
  124. <CFTREE name = "Tree"
  125.     height = "600"
  126.     width = "300"
  127.     highlightRef = "no"
  128.     >
  129.     
  130.     <!--- use the parent ID of the first item in the recordset as the root ID --->
  131.     <CFTREEITEM value="#GetTreeData.ParentItemID#" display="$${RootItem}" img="$${IconImage1}" expand="yes">
  132.  
  133.     <CFLOOP query="GetTreeData">
  134.  
  135.         <CFTREEITEM value="#ItemID#" parent="#ParentItemID#" display="#ItemID#" expand="no" img="$${IconImage2}">
  136.  
  137.     </CFLOOP>
  138.  
  139. </CFTREE>
  140.     
  141. <P>
  142.  
  143. <INPUT type="Submit" value="Open" name="btnOpen">
  144.  
  145. </CFFORM>
  146.  
  147.  
  148. </WIZIF>
  149.  
  150.  
  151. </BODY></HTML>